import { defineStore } from "pinia";
// import authMenu from "@/assets/json/authMenu.json";
// import authUser from "@/assets/json/authUser.json";
// import { listRouters as listRoutersApi } from "@/api/system/menu/index";



const defaultLoginUser = {
  userId: "",
  loginName: "",
  sex: "",
  avatar: "",
};

// 权限数据
const authStore = defineStore("auth", {
  // 存储数据state
  state: (): any => ({
    menuList: [],
    recursiveMenuList: [],
    breadcrumbList: [],
    systemsId: 0,
    roleList: [],
    buttonList: [],
    loginUser: { ...defaultLoginUser },
    menuDataList: [],
  }),
  actions: {

  },
  // 计算属性，和vuex是使用一样，getters里面不是方法，是计算返回的结果值
  getters: {
    // 按钮权限列表
    getButtonList: (state) => state.buttonList,
    // 用户信息
    getUserinfo: (state) => state.loginUser,
    // 菜单权限列表 ==> 原始后端接口菜单数据，扁平化之后的一维数组菜单，主要用来添加动态路由，隐藏和不隐藏的菜单路由都需要
    getMenuList: (state) => state.menuList,
    systemMenu: (state) => state.systemMenuList,
    // 菜单权限列表 ==> 左侧菜单栏渲染，这里的菜单将后端数据进行递归，需要将动态路由 isHide == 0 的隐藏菜单剔除, 将静态路由 isHide == 0 的隐藏菜单剔除
    showMenuList: (state) => state.recursiveMenuList,
    // 递归处理后的所有面包屑导航列表
    // getBreadcrumbList: (state) => getAllBreadcrumbList(state.breadcrumbList),
    // 从localStorage获取默认路由地址
    // redirectPathByLocalStorage: (state) => getRedirectPathByLocalStorage(state.menuDataList)
  },
});

// 对外暴露方法
export default authStore;
